﻿<html>

<head>
<meta http-equiv=Content-Type content="text/html; charset=UTF-8">
<meta name=Generator content="Microsoft Word 14 (filtered)">
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:宋体;
	panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
	{font-family:宋体;
	panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
	{font-family:"\@宋体";
	panose-1:2 1 6 0 3 1 1 1 1 1;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:"Times New Roman","serif";}
h1
	{mso-style-link:"标题 1 Char";
	margin-right:0cm;
	margin-left:0cm;
	font-size:24.0pt;
	font-family:宋体;}
h3
	{mso-style-link:"标题 3 Char";
	margin-top:13.0pt;
	margin-right:0cm;
	margin-bottom:13.0pt;
	margin-left:0cm;
	text-align:justify;
	text-justify:inter-ideograph;
	line-height:173%;
	page-break-after:avoid;
	font-size:16.0pt;
	font-family:"Times New Roman","serif";}
p.MsoHeader, li.MsoHeader, div.MsoHeader
	{margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	layout-grid-mode:char;
	border:none;
	padding:0cm;
	font-size:9.0pt;
	font-family:"Times New Roman","serif";}
p.MsoFooter, li.MsoFooter, div.MsoFooter
	{margin:0cm;
	margin-bottom:.0001pt;
	layout-grid-mode:char;
	font-size:9.0pt;
	font-family:"Times New Roman","serif";}
span.1Char
	{mso-style-name:"标题 1 Char";
	mso-style-link:"标题 1";
	font-family:宋体;
	font-weight:bold;}
span.3Char
	{mso-style-name:"标题 3 Char";
	mso-style-link:"标题 3";
	font-weight:bold;}
 /* Page Definitions */
 @page WordSection1
	{size:595.3pt 841.9pt;
	margin:72.0pt 90.0pt 72.0pt 90.0pt;
	layout-grid:15.6pt;}
div.WordSection1
	{page:WordSection1;}
 /* List Definitions */
 ol
	{margin-bottom:0cm;}
ul
	{margin-bottom:0cm;}
-->
</style>

</head>

<body bgcolor=white lang=ZH-CN style='text-justify-trim:punctuation'>

<div class=WordSection1 style='layout-grid:15.6pt'>

<h1 align=center style='text-align:center'>分支结构</h1>

<p class=MsoNormal style='line-height:16.5pt'><span style='font-family:宋体;
color:#555555'>在程序中经常需要比较两个量的大小关系，以决定程序下一步的工作。比较两个量的运算符称为关系运算符。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial'>
<br>
</span></p>

<h3 style='margin:0cm;margin-bottom:.0001pt;line-height:30.0pt;vertical-align:
middle'><span style='text-decoration:initial'><span lang=EN-US
style='font-size:12.0pt;font-family:"Tahoma","sans-serif";color:red;border:
none windowtext 1.0pt;padding:0cm'>5.1.1</span><span style='font-size:12.0pt;
font-family:宋体;color:red;border:none windowtext 1.0pt;padding:0cm'>关系运算符及其优先次序</span></span></h3>

<p class=MsoNormal style='line-height:16.5pt'><span style='font-family:宋体;
color:#555555'>在Ｃ语言中有以下关系运算符：</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'><br style='text-decoration:initial'>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt'><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'>1.<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'>&lt;&nbsp;&nbsp; </span><span style='font-family:宋体;color:#555555'>小于</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt'><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'>2.<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'>&lt;=&nbsp; </span><span style='font-family:宋体;color:#555555'>小于或等于</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt'><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'>3.<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'>&gt;&nbsp;&nbsp; </span><span style='font-family:宋体;color:#555555'>大于</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt'><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'>4.<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'>&gt;=&nbsp; </span><span style='font-family:宋体;color:#555555'>大于或等于</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt'><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'>5.<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'>==&nbsp; </span><span style='font-family:宋体;color:#555555'>等于</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt'><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'>6.<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'>!=&nbsp; </span><span style='font-family:宋体;color:#555555'>不等于</span></p>

<p class=MsoNormal style='line-height:16.5pt'><span style='font-family:宋体;
color:#555555'>关系运算符都是双目运算符，其结合性均为左结合。关系运算符的优先级低于算术运算符，高于赋值运算符。在六个关系运算符中，</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>&lt;,&lt;=,&gt;,&gt;=</span><span
style='font-family:宋体;color:#555555'>的优先级相同，高于</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>==</span><span
style='font-family:宋体;color:#555555'>和</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'>!=</span><span style='font-family:宋体;
color:#555555'>，</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'>==</span><span style='font-family:宋体;color:#555555'>和</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>!=</span><span
style='font-family:宋体;color:#555555'>的优先级相同。</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'><br style='text-decoration:
initial'>
<br>
</span></p>

<h3 style='margin:0cm;margin-bottom:.0001pt;line-height:30.0pt;vertical-align:
middle'><span style='text-decoration:initial'><span lang=EN-US
style='font-size:12.0pt;font-family:"Tahoma","sans-serif";color:red;border:
none windowtext 1.0pt;padding:0cm'>5.1.2</span><span style='font-size:12.0pt;
font-family:宋体;color:red;border:none windowtext 1.0pt;padding:0cm'>关系表达式</span></span></h3>

<p class=MsoNormal style='line-height:16.5pt'><span style='font-family:宋体;
color:#555555'>关系表达式的一般形式为：表达式</span><span style='font-family:"Tahoma","sans-serif";
color:#555555'> </span><span style='font-family:宋体;color:#555555'>关系运算符</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>&nbsp; </span><span
style='font-family:宋体;color:#555555'>表达式</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'><br style='text-decoration:
initial'>
<br style='text-decoration:initial'>
</span><span style='font-family:宋体;color:#555555'>例如：</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'><br style='text-decoration:
initial'>
a+b&gt;c-d<br style='text-decoration:initial'>
x&gt;3/2<br style='text-decoration:initial'>
‘a’+1&lt;c<br style='text-decoration:initial'>
-i-5*j==k+1<br style='text-decoration:initial'>
</span><span style='font-family:宋体;color:#555555'>都是合法的关系表达式。由于表达式也可以又是关系表达式。</span><span
style='font-family:"Tahoma","sans-serif";color:#555555'> </span><span
style='font-family:宋体;color:#555555'>因此也允许出现嵌套的情况。例如：</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'><br style='text-decoration:
initial'>
a&gt;(b&gt;c)<br style='text-decoration:initial'>
a!=(c==d)<br style='text-decoration:initial'>
</span><span style='font-family:宋体;color:#555555'>等。</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'><br style='text-decoration:
initial'>
<br style='text-decoration:initial'>
</span><span style='font-family:宋体;color:#555555'>关系表达式的值是真</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>”</span><span
style='font-family:宋体;color:#555555'>和</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'>“</span><span style='font-family:宋体;
color:#555555'>假</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'>”</span><span style='font-family:宋体;color:#555555'>，用</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>“1”</span><span
style='font-family:宋体;color:#555555'>和</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'>“0”</span><span style='font-family:宋体;
color:#555555'>表示。如：</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'><br style='text-decoration:initial'>
&nbsp; 5&gt;0</span><span style='font-family:宋体;color:#555555'>的值为</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>“</span><span
style='font-family:宋体;color:#555555'>真</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'>”</span><span style='font-family:宋体;
color:#555555'>，即为</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'>1</span><span style='font-family:宋体;color:#555555'>。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial'>
(a=3)&gt;(b=5)</span><span style='font-family:宋体;color:#555555'>由于</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>3&gt;5</span><span
style='font-family:宋体;color:#555555'>不成立，故其值为假，即为</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>0</span><span
style='font-family:宋体;color:#555555'>。</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'><br style='text-decoration:initial'>
<br style='text-decoration:initial'>
</span><span style='font-family:宋体;color:#555555'>【例</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>5.1</span><span
style='font-family:宋体;color:#555555'>】</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'><br style='text-decoration:initial'>
main(){<br style='text-decoration:initial'>
&nbsp; char c='k';<br style='text-decoration:initial'>
&nbsp; int i=1,j=2,k=3;<br style='text-decoration:initial'>
&nbsp; float x=3e+5,y=0.85;<br style='text-decoration:initial'>
&nbsp; printf(&quot;%d,%d\n&quot;,’a’+5&lt;c,-i-2*j&gt;=k+1);<br
style='text-decoration:initial'>
&nbsp; printf(&quot;%d,%d\n&quot;,1&lt;j&lt;5,x-5.25&lt;=x+y);<br
style='text-decoration:initial'>
&nbsp; printf(&quot;%d,%d\n&quot;,i+j+k==-2*j,k==j==i+5);<br style='text-decoration:
initial'>
&nbsp;}<br style='text-decoration:initial'>
<br style='text-decoration:initial'>
</span><span style='font-family:宋体;color:#555555'>在本例中求出了各种关系运算符的值。字符变量是以它对应的</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>ASCII</span><span
style='font-family:宋体;color:#555555'>码参与运算的。对于含多个关系运算符的表达式，如</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>k==j==i+5,</span><span
style='font-family:宋体;color:#555555'>根据运算符的左结合性，先计算</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>k==j,</span><span
style='font-family:宋体;color:#555555'>该式不成立，其值为</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>0</span><span
style='font-family:宋体;color:#555555'>，再计算</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>0==i+5</span><span
style='font-family:宋体;color:#555555'>，也不成立，故表达式值为</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>0</span><span
style='font-family:宋体;color:#555555'>。</span></p>

<p class=MsoNormal align=left style='text-align:left'><span lang=EN-US>&nbsp;</span></p>

</div>

</body>

</html>
